package service;

import DTO.FootDTO;
import dao.TestDao;
import domain.Foot;

import java.util.List;
import java.util.stream.Collectors;

public class TestService {

    TestDao testDao;
    public List<FootDTO> userLikeFoot(int uid){
        List<Foot> footList = testDao.queryUserLikeFootByUserId(uid);
        List<FootDTO> result=footList.stream().map(t->{
            FootDTO dto=new FootDTO();
            dto.setCalorie(t.getCalorie());
            dto.setName(t.getName());
            return dto;
        }
        ).collect(Collectors.toList());

        return result;
    }

    public List<FootDTO> userLikeFoot(int uid,int id){
        List<Foot> footList = testDao.queryUserLikeFootByUserId(uid);
        List<FootDTO> result=footList.stream().map(t->{
                    FootDTO dto=new FootDTO();
                    dto.setCalorie(t.getCalorie());
                    dto.setName(t.getName());
                    return dto;
                }
        ).collect(Collectors.toList());

        return result;
    }

    public TestService(TestDao testDao){
        this.testDao=testDao;
    }
}
